from django.contrib.auth import get_user_model

from apps.vadmin.permission.permissions import CommonPermission
from apps.vadmin.op_drf.viewsets import CustomModelViewSet
from apps.vadmin.analysis.models import Batch
from apps.vadmin.analysis.filters import BatchFilter
from apps.vadmin.analysis.serializers import BatchSerializer, BatchCreateUpdateSerializer
UserProfile = get_user_model()

class BatchModelViewSet(CustomModelViewSet):
    """
    岗位管理 的CRUD视图
    """
    queryset = Batch.objects.all()
    serializer_class = BatchSerializer
    create_serializer_class = BatchCreateUpdateSerializer
    update_serializer_class = BatchCreateUpdateSerializer
    filter_class = BatchFilter
    update_extra_permission_classes = (CommonPermission,)
    destroy_extra_permission_classes = (CommonPermission,)
    create_extra_permission_classes = (CommonPermission,)
    search_fields = ('batch_num',)
    ordering = ['batch_num', 'create_datetime']  # 默认排序

